From: Jo-Philipp Wich Date: Wed, 9 Nov 2022 19:37:54 +0000 (+0100) Subject: luci-lua-runtime: also search luci.dispatcher scope when looking up values X-Git-Url: http://git.openwrt.org/%22https:/collectd.org//%22/%22https:/collectd.org/%22?a=commitdiff_plain;h=fd7427c4e50564c2428377259f988df4ed785733;p=project%2Fluci.git luci-lua-runtime: also search luci.dispatcher scope when looking up values Some legacy templates access dispatcher functions such as `build_url()` without explicit scope, which worked in the old runtime since the template view namespace was instantiated from the dispatcher. Ensure that this continues to function in the emulated runtime. Fixes: #6082 Signed-off-by: Jo-Philipp Wich --- diff --git a/modules/luci-lua-runtime/luasrc/template.lua b/modules/luci-lua-runtime/luasrc/template.lua index b6b9af0bad..84fb8bb338 100644 --- a/modules/luci-lua-runtime/luasrc/template.lua +++ b/modules/luci-lua-runtime/luasrc/template.lua @@ -121,7 +121,7 @@ context.viewns = setmetatable({ elseif key == "resource" then return L.config.main.resourcebase else - return rawget(tbl, key) or _G[key] or L[key] + return rawget(tbl, key) or disp[key] or _G[key] or L[key] end end})